package com.trkj.service;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.trkj.dao.jpa.IBuildDao;
import com.trkj.pojos.Build;
import com.trkj.pojos.Floor;
import com.trkj.vo.BuildVo;
import com.trkj.vo.FloorVo;
@Service
@Transactional
public class BulidService {
	@Autowired
	private IBuildDao iBuildDao;
	/**
	 * 获取全部住院大楼
	 * @return
	 */
	public List<BuildVo> queryAllLiveBuild(){
		
		List<BuildVo>  list = iBuildDao.queryAllLiveBuild();
		return list;
	}
	/**
	 * 查询指定住院大楼下的楼层
	 * @param buildID
	 * @return
	 */
	public List<FloorVo> queryUnderBuildFloors(String buildID){
		
		Build build = iBuildDao.findOne(buildID);
		List<Floor> Floors = build.getFloors();
		List<FloorVo> floorVos = new ArrayList<>();
		
		if(Floors!=null){
			for(Floor floor : Floors){
				FloorVo floorVo = new FloorVo();
				floorVo.setFloorId(floor.getFloorId());
				floorVo.setName(floor.getFloorname());
				floorVos.add(floorVo);
			}
		}
		return floorVos;
	}
	
	
	
}
